# config.py
from dataclasses import dataclass
import yaml
from dotenv import load_dotenv



# 1. 加载 .env 文件（敏感信息）
load_dotenv()

# 2. 读取 YAML（非敏感配置）
with open("config.yaml", "r", encoding="utf-8") as f:
    yaml_config = yaml.safe_load(f)

@dataclass
class Config:
    # 检查参数：
    # 1.应该有默认值，防止未配置时报错
    # 2.对于路径，需要判断路径是否存在，若不存在则创建


    # === 非敏感信息：来自 YAML ===
    ASR_TYPE = yaml_config["asr"]["asr_type"]
    SENSE_VOICE_ASR_MODEL = yaml_config["asr"]["sense_voice_asr"]["model"]
    QWEN3_ASR_MODEL = yaml_config["asr"]["qwen3_asr"]["model"]



    LLM_TYPE = yaml_config["llm"]["llm_type"]

    OLLAMA_HOST = yaml_config["llm"]["ollama"]["host"]
    OLLAMA_MODEL = yaml_config["llm"]["ollama"]["model"]
    QWEN_MODEL = yaml_config["llm"]["qwen"]["model"]

    # 当前角色
    CURRENT_CHARACTER = yaml_config["characters"]["current_character"]

    #AUDIO_OUTPUT_PATH = yaml_config["audio"]["output_file_path"]
    #AUDIO_INPUT_PATH = yaml_config["audio"]["input_file_path"]
    TTS_TYPE = yaml_config["tts"]["tts_type"]
    TTS_FILE_OUT_PATH = yaml_config["tts"]["file_out_path"]  # 指定返回音频文件存放路径,绝对路径
    #TTS_SAVE_FILES = yaml_config["tts"]["save_files"]
    GPT_SOVITS_HOST = yaml_config["tts"]["gpt_sovits"]["host"]
    GPT_SOVITS_REFERENCE_AUDIO_PATH = yaml_config["tts"]["gpt_sovits"]["reference_audio_path"]
    GPT_SOVITS_REFERENCE_AUDIO_TEXT = yaml_config["tts"]["gpt_sovits"]["reference_audio_text"]
    GPT_SOVITS_REFERENCE_AUDIO_LANG = yaml_config["tts"]["gpt_sovits"]["reference_audio_lang"]
    GPT_SOVITS_GPT_MODEL = yaml_config["tts"]["gpt_sovits"]["gpt_model"]
    GPT_SOVITS_SOVITS_MODEL = yaml_config["tts"]["gpt_sovits"]["sovits_model"]

    sqlite_db_path = yaml_config["sqlite"]["db_path"]

# 全局配置实例
app_config = Config()
print("app_config init end")